use std::fs::File;
use std::io::ErrorKind;

fn main() {
    // File::create("./abc.xls").expect("Success");
    // let f = File::open("./abc.xls");
    // let f = match f {
    //     Ok(s) => {
    //         println!("{:?}", s);
    //         s
    //     }
    //     Err(e) => {
    //         panic!("{}", e.to_string())
    //     }
    // };
    let f = File::open("hello.txt").map_err(|error| {
       if error.kind() == ErrorKind::NotFound{
           File::create("hello.txt").unwrap_or_else(|err| {
               panic!("Tried to create the file but there is an error: {}", err);
           })
       }else{
           panic!("Tried to open the file but there is an error: {}", error);
       }
    });

    println!("{:?}", f);
}
